package com.gang.controller;

import com.gang.conf.FiscoBcos;

import org.fisco.bcos.sdk.client.Client;
import org.fisco.bcos.sdk.client.protocol.response.BlockNumber;
import org.fisco.bcos.sdk.crypto.CryptoSuite;
import org.fisco.bcos.sdk.crypto.keypair.CryptoKeyPair;
import org.fisco.bcos.sdk.crypto.signature.ECDSASignature;
import org.fisco.bcos.sdk.model.CryptoType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@RequestMapping("/block")
@Controller
public class TestController {

    @Autowired
    FiscoBcos fiscoBcos;

    @RequestMapping("/get")
    @ResponseBody
    public List get(){
        CryptoSuite cryptoSuite = new CryptoSuite(CryptoType.ECDSA_TYPE);
        CryptoKeyPair keyPair = cryptoSuite.createKeyPair();
        String hexPrivateKey = keyPair.getHexPrivateKey();
        String hexPublicKey = keyPair.getHexPublicKey();
        String address = keyPair.getAddress();
        List<String> strings = new ArrayList<>();
        ECDSASignature ecdsaSignature = new ECDSASignature();
        strings.add(hexPrivateKey);
        strings.add(hexPublicKey);
        return strings;
    }
}
